﻿Type=Activity
Version=3.15
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: True
	#IncludeTitle: False
#End Region

Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.

End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.

	Dim pnlIMG As Panel
	Dim btnOK As Button
	Dim btnNew As Button
	
	Dim MyCamera As Camera
	Dim FTitle As String
	
	FTitle = "获取图片"
	Dim btnNew As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
	Activity.LoadLayout("FormJZCamera")
	Activity.Title = FTitle 

	btnOK.Enabled = False
	MyCamera.Initialize(pnlIMG,"MyCamera")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)
	MyCamera.Release
End Sub

Sub MyCamera_Ready (Success As Boolean)
  If Success Then
    MyCamera.StartPreview
    btnOK.Enabled = True
  Else
    ToastMessageShow("不能打开相机.", True)
  End If
End Sub

Sub MyCamera_PictureTaken (Data() As Byte)
  Dim out As OutputStream
  out = File.OpenOutput(PublicVar.GV_IMG_DIR, "1.jpg", False)
  out.WriteBytes(Data, 0, Data.Length)
  out.Close
  ToastMessageShow("图片已保存: " & File.Combine(PublicVar.GV_IMG_DIR, "1.jpg"), True)
End Sub	

Sub btnOK_Click
	MyCamera.TakePicture
	
End Sub


Sub btnNew_Click
	MyCamera.StartPreview
End Sub